<?php
//  ------------------------------------------------------------------------ //
//                          SHORTCUTS FOR XOOPS 2                            //
//                  Copyright (c) 2005-2006 Instant Zero                     //
//                     <http://xoops.instant-zero.com/>                      //
// ------------------------------------------------------------------------- //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the GNU General Public License as published by     //
//  the Free Software Foundation; either version 2 of the License, or        //
//  (at your option) any later version.                                      //
//                                                                           //
//  You may not change or alter any portion of this comment or credits       //
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //

include_once '../../../include/cp_header.php';

xoops_cp_header();

if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) {
	$errors=0;
	// 1) Add the new fields to the topic table
	$sql=sprintf("ALTER TABLE " . $xoopsDB->prefix('shortcuts') . " ADD rating TINYINT( 4 ) DEFAULT '0' NOT NULL ;");
	$result=$xoopsDB->queryF($sql);
	if (!$xoopsDB->queryF($sql)) {
    	echo _SHORTCUTS_UPGRADEFAILED.' '._AM_SHORTCUTS_UPGRADEFAILED21;
    	$errors++;
	}

    // At the end, if there was errors, show them or redirect user to the module's upgrade page
	if($errors) {
		echo "<H1>" . _AM_SHORTCUTS_UPGRADEFAILED . "</H1>";
		echo "<br />" . _AM_SHORTCUTS_UPGRADEFAILED0;
	} else {
		echo _AM_SHORTCUTS_UPGRADECOMPLETE." - <a href='".XOOPS_URL."/modules/legacy/admin/index.php?action=ModuleUpdate&dirname=shortcuts'>"._AM_UPDATEMODULE."</a>";
	}
} else {
	printf("<H2>%s</H2>\n",_AM_SHORTCUTS_UPGR_ACCESS_ERROR);
}
xoops_cp_footer();
?>